package utiltest;

import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;

public class Algori {

    private void reverse(char[] s) {
        int l = 0, r = s.length - 1;
        while (l <= r) {
            char t = s[l];
            s[l] = s[r];
            s[r] = t;
            l++;
            r--;
        }
    }

    private void removeZero(int[] nums) {
        int n = nums.length, l = 0, r = 0;

        while (r < n) {
            if (nums[r] != 0) {
                int t = nums[l];
                nums[l] = nums[r];
                nums[r] = t;

                l++;
            }
            r++;
        }

    }


    private void t1(int[] nums) {
        // define index
        int index = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != 0 ) {
                index = i;
            }
        }

        for (int j = 0; j < nums.length; j++) {

            if (nums[j] == 0 ) {
                for (int i = index - 1; i < nums.length - 1; i++) {
                    nums[i] = nums[i + 1];
                }
                nums[nums.length - 1] = 0;
            }
        }


    }


    public void getJson(String param) {

        JSONObject jsonObject = JSONObject.parseObject(param);

        jsonObject.keySet().forEach(e -> {
            jsonObject.getString(e);
        });

    }

    public void moveZero(int[] nums) {

        int[] zeroPos = new int[nums.length];
        var list = new ArrayList<Integer>();

        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0) {
                list.add(i);
            }
        }

        for (int i = 0; i < list.size(); i++) {

        }

    }
}
